namespace hjc {

	export class ControllerManager extends Singleton implements ILaunchable {

		private $controllers: Controller[] = [];
		public launch(options: LaunchOptions): void {
			if (notEmptyArr(options.Controllers))
				options.Controllers.unique().forEach((clazz: new () => Controller) => this.$controllers.push(new clazz()));
		}

		public get<C extends Controller>(clazz: new () => C): C {
			for (let controller of this.$controllers) {
				if (controller instanceof clazz) return controller;
			}
			let controller = new clazz();
			this.$controllers.push(controller);
			return controller;
		}

		public getAll(): Controller[] { return this.$controllers; }
	}

}